package com.example.databindingdemo.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import com.example.databindingdemo.R;
import com.example.databindingdemo.databinding.ActivityBindingAdapterBinding;
import com.example.databindingdemo.utils.Constants;

/**
 * @author: njb
 * @date: 2022/9/18 0:41
 * @desc:
 */
public class BindAdapterActivity extends AppCompatActivity {
    private ActivityBindingAdapterBinding bindingAdapterBinding;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
    }

    private void initView() {
        bindingAdapterBinding = DataBindingUtil.setContentView(this, R.layout.activity_binding_adapter);
        bindingAdapterBinding.setLocalImage(R.mipmap.ic_launcher);
        bindingAdapterBinding.setNetWorkImage(Constants.imgUrl);
        bindingAdapterBinding.setImagePadding(Constants.oldPadding);
        bindingAdapterBinding.setClickHandler(new ClickHandler());
    }

    public class ClickHandler {
        public void onClick(View view){
            bindingAdapterBinding.setImagePadding(Constants.newPadding);
            startActivity(new Intent(BindAdapterActivity.this,TwoWayBindingViewModelActivity.class));
        }
    }
}
